<?php
/** Copyright 2014 TinPhp Systems, Inc.
 * @author zhangxilian 2013-8-15
 */
if (! defined ( 'IN_TINPHP' )) {
	exit ( 'Access Denied' );
}

require_once (TIN_APP_PATH . 'include/TinAppController.php');
require_once (TIN_APP_PATH . 'include/Auth.php');
require_once TIN_APP_PATH . "app/view/AssignTable.php";
require_once TIN_APP_PATH . "app/view/AssignView.php";
require_once(TIN_APP_PATH . 'include/utils/page.php');

/**
 * 前台APP基类
 */
class IndexAppController extends TinAppController {
	public $user;
	public function __construct() {
		parent::__construct();
		$this->setPageHeader();
		$this->user = Auth::getUserInfo();
                T::$tpl->set('user',$this->user);
		$this->initPage();
	}
	
	private function initPage() {
		// 如果不是Ajax请求则默认执行初始界面，根据Action前4位作为判断
		if (strtolower ( substr ( T::$action, 0, 4 ) ) == "ajax") {
			T::$tplFile = "public/empty";
			return;
		}
		//初始基类公共部分
                
		
	}
    public function get_arrchildid($catid) {
        $arrchildid = $catid;
        $artLogic = new ArticleLogic();
        $cats =$artLogic->getCatAll("*",'','');
        foreach($cats as  $cat) {
            if($cat['PARENT_ID'] && $cat['PARENT_ID']==$catid) {
                $arrchildid .= ','.$this->get_arrchildid($cat['ID']);
            }
        }
        return $arrchildid;
    }
    public function get_arrparentid($catid, $arrparentid = '', $n = 1) {
        $cats =$artLogic->getCatItem("*","ID=".$catid);
        if($n > 5 || !is_array($cats)) return false;
        $parentid = $cats['PARENT_ID'];
        $arrparentid = $arrparentid ? $parentid.','.$arrparentid : $parentid;
        if($parentid) {
            $arrparentid = $this->get_arrparentid($parentid, $arrparentid, ++$n);
        } else {
            $cats['arrparentid'] = $arrparentid;
        }
        $parentid = $cats['PARENT_ID'];
        return $arrparentid;
    }
} // End Class
?>
